<?php
class PendaftaranControl extends CI_controller {

    function __construct() {
        parent::__construct();
        $this->load->helper('url');
        $this->load->helper('form');
        $this->load->model('userModel');
        $this->load->model('TahapanusiaModel');
        $this->load->model('usiaUserModel');
    }

    function index() {
        $this->load->helper('url');
        $this->load->library('form_validation');
        $this->form_validation->set_rules('username',  'Name',  'required');
        $this->form_validation->set_rules('email',  'Email',  'required|valid_email');
        $this->form_validation->set_rules('password',  'Password',  'required|min_length[5]');

        if ($this->form_validation->run() == FALSE) {
            $this->load->view('pendaftaranForm');
        }
        else {
            $this->load->view('loginForm');
        }
    }

    function registrasi() {
        if ($this->input->post('submit')) {
            $this->load->model('userModel');
            $this->userModel->add_users();
            redirect('userPageControl');
        }
        $this->load->view('pendaftaranForm');
    }
}
?>
